import os
import re

from base_config import BASE_PATH


def read_dbc(filename: str, file_path=None, abs_path=False):
    if abs_path:
        path = filename
    else:
        if file_path:
            path = file_path + os.sep + filename
        else:
            path = BASE_PATH + os.sep + 'data' + os.sep + filename
    with open(path, "r", encoding='utf-8') as f:
        data = f.read()
    return data


if __name__ == '__main__':
    content = read_dbc(r"C:\Users\ADAO-27\Desktop\ADPUnewproject\data\SD3A私家版_通信协议_ADPU_CANFD_V4.03_20230412(1).dbc",
                       abs_path=True)
    print(content)
    result = re.findall(r' SG_ GNSSinfPVTTrack : (\d+?)\|(\d+?)@0+ \((\d+?),(\d+?)\) [-180|180]')
